package ch10_thread.thread;

/**
 * 类锁-*.Class
 *
 * @author guodd
 * @version 1.0 use jdk 1.8
 */
public class Synchronized06 implements Runnable {
    public static void main(String[] args) {
        Synchronized06 syn01 = new Synchronized06();
        Synchronized06 syn02 = new Synchronized06();
        Thread t01 = new Thread(syn01);
        Thread t02 = new Thread(syn02);
        t01.start();
        t02.start();
    }

    @Override
    public void run() {
        synchronized (Synchronized06.class) {
            System.out.println("类锁" + Thread.currentThread().getName());
            try {
                Thread.sleep(3000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            System.out.println(Thread.currentThread().getName() + "结束");
        }
    }
}
